{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ed6374f8",
   "metadata": {},
   "source": [
    "## 本周学习内容\n",
    "- 1.字典的循环遍历\n",
    "- 2.字典的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "42c958a1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-01T02:01:59.244665Z",
     "start_time": "2021-11-01T02:01:59.232664Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu1801': 'ZiQi', 'stu1802': 'XiaoFeng', 'stu1803': 'LiuYu'}\n"
     ]
    }
   ],
   "source": [
    "info = {\n",
    "    \"stu1801\":\"ZiQi\",\n",
    "    \"stu1802\":\"XiaoFeng\",\n",
    "    \"stu1803\":\"LiuYu\"\n",
    "}\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e4f07ed4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-01T02:02:32.860720Z",
     "start_time": "2021-11-01T02:02:32.854717Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu1801\n",
      "stu1802\n",
      "stu1803\n"
     ]
    }
   ],
   "source": [
    "for i in info:\n",
    "    print(i)      # i 只是key的值，并没有真正意义上获取到字典的完整信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "edc64396",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-01T02:08:31.122192Z",
     "start_time": "2021-11-01T02:08:31.116191Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu1801 ZiQi\n",
      "stu1802 XiaoFeng\n",
      "stu1803 LiuYu\n"
     ]
    }
   ],
   "source": [
    "# 字典的循环 如何循环 key:value 作为 items 输出\n",
    "for k,v in info.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "85287c96",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-01T02:18:46.607482Z",
     "start_time": "2021-11-01T02:18:46.590463Z"
    }
   },
   "outputs": [],
   "source": [
    "# 实践1：学号的k 去掉stu 然后输出新的字典\n",
    "new_info = {}\n",
    "\n",
    "for k,v in info.items():\n",
    "    # 字典的新增 \n",
    "    new_info[k[3:]] = v.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7fc3073b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-01T02:18:51.574777Z",
     "start_time": "2021-11-01T02:18:51.559780Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'1801': 'ZIQI', '1802': 'XIAOFENG', '1803': 'LIUYU'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bec87f37",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
